package pojo;

import lombok.Data;
import tool.LogCat;

import java.io.Serializable;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;

//电影类
@Data
public class Movie implements Serializable {
    //编号
    private String id="";
    //电影名
    private String name="";
    //电影类型
    private String type="";
    //上映时间
    private Time releaseTime;
    //电影总评分(改成总评分了)
    private Integer score;
    //平均分数
    private Double averageScore;
    //评价人数
    private Integer evaluateCount;
    //特殊:临时分数
    private Integer tempScore;

    //构造方法-特殊
    public Movie(String id, String name, String type, String  releaseTime, String  score) {
        this.id = id;
        this.name = name;
        this.type = type;
        this.releaseTime = new Time(releaseTime);
        this.score = Integer.parseInt(score);
    }

    //构造方法-特殊
    public Movie(String id, String name, String type, String  releaseTime/*, String  score*/) {

        this.id = id;
        LogCat.d("id: " + id);
        this.name = name;
        LogCat.d("name: " + name);
        this.type = type;
        LogCat.d("type: " + type);
        this.releaseTime = new Time(releaseTime);
        LogCat.d("releaseTime: " + releaseTime);
        //this.score = Integer.parseInt(score);
    }

    //重写HashCode和Equals方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Movie movie = (Movie) o;
        return /*score == movie.score &&*/ Objects.equals(id, movie.id) && Objects.equals(name, movie.name) && Objects.equals(type, movie.type) && Objects.equals(releaseTime, movie.releaseTime);
    }
    @Override
    public int hashCode() {
        return Objects.hash(id, name, type, releaseTime/*, score*/);
    }

    @Override
    public String toString() {
        return "编号:"+id+" 电影名:"+name+" 类型:"+type+" 上映时间:"+releaseTime+" 评分:"+score;
    }
}
